// pages/post/search/search.js
var app = getApp();
Page({
  data: {
    matchPost:[],
    show:false,
    province:'',
  },
  onLoad: function (options) {
    var that = this;
    var pro = app.globalData.provinceSelected;
    if (pro == "" || pro == "全国") {
      that.setData({
        province: "全国"
      })
    }
    else {
      that.setData({
        province: pro
      })
    }
  },
  bindInput:function(e){
    var that = this;
    if(e.detail.value){
      wx.request({
      url: 'http://106.15.201.147/wx_admin/jobs/jobList',
      method: 'post',
      header: {
      'Content-Type': 'application/json'
      },
      data: {
      "searchValue": e.detail.value
      },
      success: function (res) {
        that.setData({
          matchPost: res.data,
          show: true
        })
        console.log(that.data.matchPost)
      }
    });
  }else{
      that.setData({
        matchPost:'',
        show: false
      })
  }   
},
  jobDetail: function (e) {
    var that = this;
    var postId = e.currentTarget.dataset.postid;
    wx.navigateTo({
      url: '../../jobDetail/jobDetail?id=' + JSON.stringify(postId)
    })
  },
  switchProvince: function () {
    wx.navigateTo({
      url: '../../switchProvince/switchProvince',
    })
  }
})